var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);

var that = {};

// 初始化 socket连接
var initSocket = function() {
  console.log('initSocket');
  // io.on("connection", function(socket){
  //   console.log( "initSocket success" );
  // });
};

// 接收消息
var onMessage = function(port) {
  http.listen(port, function(message){
    console.log('正在监听3000端口');
    console.log(message);
  });
};

// 推送消息
var sendMessage = function(message) {
  io.sockets.emit('change', {
    name: 'MacBook Pro'
  });
};

that.initSocket = initSocket;
that.onMessage = onMessage;
that.sendMessage = sendMessage;
module.exports = that;
